package com.haoshuang.zhouzhoubang.ui.adapter

import com.haoshuang.zhouzhoubang.databinding.ItemBalanceWithdrawalDetailBinding
import com.haoshuang.zhouzhoubang.model.bean.WithdrawalDetailsBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.gone
import com.mufeng.libs.utils.view.visible
import com.mufeng.libs.utils.view.visibleOrGone

/**
 *
 */
class BalanceWithdrawalDetailAdapter(data: MutableList<WithdrawalDetailsBean>) :
    BaseBindingQuickAdapter<WithdrawalDetailsBean, ItemBalanceWithdrawalDetailBinding>(data) {

    override fun onBindViewHolder(
        holder: BaseBindingHolder,
        position: Int,
        item: WithdrawalDetailsBean?
    ) {

        holder.getViewBinding<ItemBalanceWithdrawalDetailBinding>().apply {
            tvTime.text = item?.add_time
            tvMoney.text = "￥${item?.extract_price}"
            tvPayment.text = "提现至：${item?.extract_type_text}"
            tvStatus.visibleOrGone(item?.status == 0)
            llRefuse.visibleOrGone(item?.status == -1)
            tvRefuse.text = "拒绝原因：${item?.fail_msg}"

            tvServiceMoney.text = "￥${item?.deductionmoney}"
            tvRealMoney.text = "￥${item?.realmoney}"

            val liquidated_damages = item?.liquidated_damages?.toDoubleOrNull()?:0.0
            if (liquidated_damages == 0.0){
                llLiquidatedDamages.gone()
            }else{
                llLiquidatedDamages.visible()
                tvLiquidatedDamages.text = "-￥${item?.liquidated_damages}"
            }

        }

    }
}
